package com.bdsy.business.controller;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.bdsy.api.annotation.IgnoreAuth;
import com.bdsy.business.model.FeedbackInfo;
import com.bdsy.business.service.FeedbackInfoServcie;
import com.bdsy.common.annotation.Json;
import com.bdsy.common.utils.Result;
import com.bdsy.system.annotation.SysLog;

/**
 * 反馈与建议
 * @author MING
 * @date 2018年1月18日 下午4:12:33
 */

@Controller
@RequestMapping(value = {"${web.adminPath}", "${web.appPath}"})
public class FeedbackInfoController {

	@Autowired
	FeedbackInfoServcie feedbackInfoServcie;
	
	
	
	@RequestMapping(value = "feedback")
	public String feedback() {
		return "admin/business/feedback";
	}
	
	/**
	 * 根据用户id查询反馈信息
	 */
	@IgnoreAuth
	@Json
	@RequestMapping(value = "feedbackInfoListById")
	public Object feedbackInfoListById(String userId) {
		Map<String,Object> map = new LinkedHashMap<>();
		List<Map> feedbackInfoList = feedbackInfoServcie.feedbackInfoListById(userId);
		map.put("code", 200);
		map.put("msg", "success");
		map.put("data", feedbackInfoList);
		return map;
	}
	
	/**
	 * 查询反馈信息 
	 */
	@Json
	@RequestMapping(value = "feedbackInfoList")
	public Object feedbackInfoList() {
		Map<String,Object> map = new LinkedHashMap<>();
		List<Map> feedbackInfoList = feedbackInfoServcie.feedbackInfoList();
		map.put("code", 200);
		map.put("msg", "success");
		map.put("data", feedbackInfoList);
		return map;
	}
	
	/**
	 * 添加反馈信息 
	 */
	@IgnoreAuth
	@Json
	@RequestMapping(value = "addfeedbackInfo")
	public Object addfeedbackInfo(FeedbackInfo feedbackInfo) {
		boolean result = feedbackInfoServcie.insert(feedbackInfo);
		if (result) {
			return Result.ok("addSuccess");
		} else {
			return Result.error("addFail");
		}
	}
	
}
